package my.springboot.jpa;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.MappedSuperclass;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

/**
 * 基础时间实体
 * @author xsw
 * @date 2018-6-25
 */
@MappedSuperclass
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class DateDO {

	@Temporal(TemporalType.TIMESTAMP)
	@CreationTimestamp
	@Column(name = "create_time", columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP", insertable = true, updatable = false)
	private Date create_time;


	@Temporal(TemporalType.TIMESTAMP)
	@UpdateTimestamp
	@Column(name = "update_time", columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP", insertable = true, updatable = true)
	private Date update_time;


    public Date getUpdate_time() {
        return update_time;
    }

    public void setUpdate_time(Date updateTime) {
        update_time = updateTime;
    }

    public Date getCreate_time() {
        return create_time;
    }

    public void setCreate_time(Date createTime) {
        create_time = createTime;
    }

}

